package com.atguigu.day211105.work;

public class Homework1 {
    public static void feed(Pet pet) {
        pet.eat();
    }

    public static void main(String[] args) {
        Pet[] pets = new Pet[2];
        pets[0] = new Dog("狗", "阿大", 20);
        pets[1] = new Cat("猫", "阿二", 10);
        for (int i =0;i<pets.length;i++){
            feed(pets[i]);
            System.out.println(pets[i].getInfo());

            if (pets[i] instanceof Dog){
                ((Dog)pets[i]).watchHouse();
            }else if (pets[i] instanceof Cat){
                ((Cat)pets[i]).catchMouse();
            }
        }
    }
}
